//@version=5
indicator("Price Momentum Oscillator with Fixed Values", shorttitle="PMO", overlay=false)

// Input settings
useFixedValue = input.bool(false, title="Fixed Value")
assetType = input.string("forex", title="Asset Type", options=["forex", "crypto", "stocks", "metals"])
timeFrame = input.string("1d", title="Time Frame", options=["4h", "1d"])

// Default Length inputs
userFirstLength = input.int(35, minval=1, title="1st Smoothing Length")
userSecondLength = input.int(20, minval=1, title="2nd Smoothing Length")
userSignalLength = input.int(10, minval=1, title="Signal Length")

// Determine fixed lengths based on the selected asset type and time frame
var firstLength = userFirstLength
var secondLength = userSecondLength
var signalLength = userSignalLength

if useFixedValue
    if assetType == "forex" and timeFrame == "1d"
        firstLength := 36
        secondLength := 53
        signalLength := 31
    else if assetType == "forex" and timeFrame == "4h"
        firstLength := 5
        secondLength := 17
        signalLength := 21
    else if assetType == "crypto" and timeFrame == "1d"
        firstLength := 12
        secondLength := 14
        signalLength := 13
    else if assetType == "crypto" and timeFrame == "4h"
        firstLength := 85
        secondLength := 33
        signalLength := 27
    else if assetType == "metals" and timeFrame == "1d"
        firstLength := 5
        secondLength := 19
        signalLength := 18
    else if assetType == "metals" and timeFrame == "4h"
        firstLength := 45
        secondLength := 40
        signalLength := 9
    else if assetType == "stocks" and timeFrame == "1d"
        firstLength := 60
        secondLength := 2
        signalLength := 76
    else if assetType == "stocks" and timeFrame == "4h"
        firstLength := 72
        secondLength := 2
        signalLength := 68

// Source input
src = input.source(close, title="Source")

// PMO Calculation
pmo = ta.ema(10 * ta.ema(ta.change(src), firstLength), secondLength)
signal = ta.ema(pmo, signalLength)

// Plotting the PMO and Signal lines
plot(pmo, title="PMO", color=color.blue)
plot(signal, title="Signal", color=color.orange)
hline(0, title="Zero Line", linestyle=hline.style_dotted)

// Highlighting crossovers/crossunders if enabled
highlightCrossovers = input.bool(true, title="Highlight PMO/Signal Crossovers?")
plotshape(ta.crossover(pmo, signal) and highlightCrossovers ? pmo : na, title="PMO Crossover", location=location.bottom, style=shape.triangleup, size=size.tiny, color=color.green)
plotshape(ta.crossunder(pmo, signal) and highlightCrossovers ? pmo : na, title="PMO Crossunder", location=location.bottom, style=shape.triangledown, size=size.tiny, color=color.red)
